package com.junmeng.jdemo;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Build;
import android.os.Bundle;
import android.text.style.ReplacementSpan;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

import com.example.common.base.BaseActivityDelegate;
import com.junmeng.jdemo.alertwindow.AlertWindowActivity;
import com.junmeng.jdemo.anim.AnimListActivity;
import com.junmeng.jdemo.apng.ApngActivity;
import com.junmeng.jdemo.audio.AudioActivity;
import com.junmeng.jdemo.checkrom.CheckRomActivity;
import com.junmeng.jdemo.constraintlayout.ConstraintActivity;
import com.junmeng.jdemo.dialog.DialogShowActivity;
import com.junmeng.jdemo.drawable.DrawableActivity;
import com.junmeng.jdemo.frags.FragContainerActivity;
import com.junmeng.jdemo.gesture.DragActivity;
import com.junmeng.jdemo.gesture.GestureActivity;
import com.junmeng.jdemo.itemdecoration.ItemDecorationActivity;
import com.junmeng.jdemo.livedata.LiveDataActivity;
import com.junmeng.jdemo.matrix.MatrixActivity;
import com.junmeng.jdemo.media.MediaTestActivity;
import com.junmeng.jdemo.mediaprojection.MediaProjectionActivity;
import com.junmeng.jdemo.notification.NotificationActivity;
import com.junmeng.jdemo.particle.ParticleActivity;
import com.junmeng.jdemo.permission.PermissionActivity;
import com.junmeng.jdemo.recycler.RecyclerMainActivity;
import com.junmeng.jdemo.retrace.RetraceTestActivity;
import com.junmeng.jdemo.round_layout.RoundLayoutActivity;
import com.junmeng.jdemo.sensor.SensorTestActivity;
import com.junmeng.jdemo.setting.SettingActivity;
import com.junmeng.jdemo.statusbar.StatusBarActivity;
import com.junmeng.jdemo.throttle.ThrottleActivity;
import com.junmeng.jdemo.viewstub.ViewStubActivity;
import com.junmeng.paging3.Paging3Activity;

public class MainActivity extends BaseActivityDelegate {
    private static final String TAG = "MainActivity";

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getWindow().getDecorView().setBackgroundColor(Color.RED);
    }

    class BlockSpan extends ReplacementSpan {

        @Override
        public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, @Nullable Paint.FontMetricsInt fm) {
            return 300;
        }

        @Override
        public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, @NonNull Paint paint) {
            canvas.drawText("1234567890", x, y, paint);
        }
    }


    public void onClickFrags(View view) {
        gotoActivity(FragContainerActivity.class);
    }

    public void onClickLiveData(View view) {
        gotoActivity(LiveDataActivity.class);
    }

    public void onClickGesture(View view) {
        gotoActivity(GestureActivity.class);
    }

    public void onClickAnim(View view) {
        gotoActivity(AnimListActivity.class);
    }

    public void onClickRoundLayout(View view) {
        gotoActivity(RoundLayoutActivity.class);

    }

    public void onClickStatusBar(View view) {
        gotoActivity(StatusBarActivity.class);
    }

    public void onClickDrag(View view) {
        gotoActivity(DragActivity.class);
    }

    public void onClickRecycler(View view) {
        gotoActivity(RecyclerMainActivity.class);
    }

    public void onClickAudio(View view) {
        gotoActivity(AudioActivity.class);
    }

    public void onClickMediaProjection(View view) {
        gotoActivity(MediaProjectionActivity.class);
    }

    public void onClickNotification(View view) {
        gotoActivity(NotificationActivity.class);
    }

    public void onClickAlertWindow(View view) {
        gotoActivity(AlertWindowActivity.class);
    }

    public void onClickSetting(View view) {
        gotoActivity(SettingActivity.class);
    }

    public void onClickPaging3(View view) {
        gotoActivity(Paging3Activity.class);
    }

    public void onClickConstraint(View view) {
        gotoActivity(ConstraintActivity.class);
    }

    public void onClickDialog(View view) {
        gotoActivity(DialogShowActivity.class);
    }

    public void onClickSensor(View view) {
        gotoActivity(SensorTestActivity.class);
    }

    public void onClickMedia(View view) {
        gotoActivity(MediaTestActivity.class);
    }

    public void onClickDrawable(View view) {
        gotoActivity(DrawableActivity.class);
    }

    public void onClickCheckRom(View view) {
        gotoActivity(CheckRomActivity.class);
    }

    public void onClickParticle(View view) {
        gotoActivity(ParticleActivity.class);
    }

    public void onClickPermission(View view) {
        gotoActivity(PermissionActivity.class);
    }

    public void onClickMatrix(View view) {
        gotoActivity(MatrixActivity.class);
    }

    public void onClickViewStub(View view) {
        gotoActivity(ViewStubActivity.class);
    }

    public void onClickItemDecoration(View view) {
        gotoActivity(ItemDecorationActivity.class);
    }

    public void onClickApng(View view) {
        gotoActivity(ApngActivity.class);
    }

    public void onClickRetrace(View view) {
        gotoActivity(RetraceTestActivity.class);
    }

    public void onClickThrottle(View view) {
        gotoActivity(ThrottleActivity.class);
    }
}